package com.example.com.daervideo.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.com.daervideo.R;
import com.example.com.daervideo.activitys.users.InviteCodeActivity;

/**
 * Created by i7-1 on 2018/12/8.
 */

public class EarnMoneyActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actvity_earn_money);
        initData();
    }

    private void initData() {
        findViewById(R.id.invite_now).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(EarnMoneyActivity.this, InviteCodeActivity.class));
            }
        });
        RecyclerView recyclerView = findViewById(R.id.e_rv);
        recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
        recyclerView.setAdapter(new EAdapter());
    }

    private class EAdapter extends RecyclerView.Adapter<EHolder> {
        @Override
        public EHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View inflate = LayoutInflater.from(EarnMoneyActivity.this).inflate(R.layout.item_earn, parent, false);

            return new EHolder(inflate);
        }

        @Override
        public void onBindViewHolder(EHolder holder, int position) {
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(EarnMoneyActivity.this, InviteNumCodeActivity.class));
                }
            });
        }

        @Override
        public int getItemCount() {
            return 4;
        }
    }

    private class EHolder extends RecyclerView.ViewHolder {
        public EHolder(View inflate) {
            super(inflate);
        }
    }
}
